/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package server;

/**
 *
 * @author Alexx
 */
import java.util.Timer;
import java.util.TimerTask;

/**
 * Simple demo that uses java.util.Timer to schedule a task 
 * to execute once 5 seconds have passed.
 */

public class Reminder {
    Timer timer;
    Server srv;

    public Reminder(int seconds, Server srv) {
      this.srv = srv;
        timer = new Timer();
        timer.schedule(new RemindTask(), seconds*1000);
	}

    class RemindTask extends TimerTask {
        public void run() {
            System.out.format("Time's up!%n");
            srv.sendUser("{\"Type\": \"End\"}", -1);
            timer.cancel(); //Terminate the timer thread
        }
    }

}
